<%--
	fileName      : branchlist_role.jsp
	author        : KFZX-tangk
	createDate    : 2010-7-8  下午03:02:32
	lastModifier  : KFZX-tangk
	lastModifyDate: 2010-7-8  下午03:02:32
	description   : 角色管理模块（机构列表）
--%>
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib uri="ctp-tag" prefix="ctp" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
		<title>机构列表</title>
		<ctp:include items='borderlayout,toolbar,button,textfield,panel,tabletree,form,message_ex' />
		<%@ include file="/branch/branchlist.jsp" %>		
		<script type='text/javascript' kind='variant'>		  
		     //================================UI变量定义片段============================================================
             var layout;//页面框架布局器
             var toolbarSearchT;//搜索文本框
             var toolbar;//机构列表工具栏
             var branchTreePanel;//存放机构列表的面板
             var branchTree;//机构列表表树
             var form;//页面跳转表单
        </script>
        <script type='text/javascript' kind='event'>
            //================================函数定义片段============================================================       
            /**
             * 判断角色管理操作权限函数
             * @version	 1.0
             * @since	 1.0
             * @author	KFZX-tangk           
             */
            function isAuth(selectedLevel){
				var _fnContext = "branchlist_role.jsp" + "->isAuth()";
			    try {
                    var pAll='<ctp:out name="sessCtx.user.privilegeAll" />';//是否可管理全部机构
                    var pSelf='<ctp:out name="sessCtx.user.privilegeSelf" />';//是否可管理本机构
                    var pOther='<ctp:out name="sessCtx.user.privilegeOther" />';//可管理下级机构层级
                    var rLv='<ctp:out name="sessCtx.user.branchLevel" />'; //柜员的登陆级别 
                    var ret=privilegeJudge(pAll,pSelf,pOther,rLv,selectedLevel);//判断柜员操作级别
                    if(ret=="1" || ret=="2"){//可以进行管理
            	        return true;
                    }
                    return false;
			    } 
			    catch (e) {
			        ctp.core.log.err(_fnContext, e.message);
			    }	
			}
			            
            /**
             * 进入角色管理前参数准备函数
             * @version	 1.0
             * @since	 1.0
             * @author	KFZX-tangk           
             */
            function roleMgmt(){
				var _fnContext = "branchlist_role.jsp" + "->roleMgmt()";
			    try {
			    	var temp=branchTree.getSelectedObj()[0].ctp_ui_tableTree.data;//选择行的数据
			    	var authFlag = isAuth(temp.branchLevel);
			    	if(authFlag){
			    		toolbar.setDisable("btnOK",false,"left");
			    		form.setHiddenValue("branchId",temp.id);
			    		form.setHiddenValue("branchLevel",temp.branchLevel);
			    		form.setHiddenValue("branchParent",temp.parentName);
			    		form.setHiddenValue("branchName",temp.name);
			    	}else{
			    		toolbar.setDisable("btnOK",true,"left");
			    	}
			    } 
			    catch (e) {
			        ctp.core.log.err(_fnContext, e.message);
			    }	
			}           

            /**
             * 工具栏搜索按钮对应函数
             * @version	 1.0
             * @since	 1.0
             * @author	KFZX-tangk           
             */
            function toolbarSearch(){
            	 var _mContext = "branchlist_role.jsp -> toolbarSearch()";
            	 try {
            	 	var _searchValue=toolbarSearchT.getValue();//取得搜索的文本
					branchTree.searchInTableCell(_searchValue);
            	 }
            	 catch (e) {
                     ctp.core.log.err(_mContext, e.message);
                 }            	 
            }
            /**
             * 表单提交按钮执行函数
             * @version	 1.0
             * @since	 1.0
             * @author	KFZX-tangk           
             */
            function formSubmit(){
            	 var _mContext = "branchlist_role.jsp -> formSubmit()";
            	 try {
            	 	 var temp=branchTree.getSelectedObj()[0].ctp_ui_tableTree.data;//选择行的数据
            		 if(temp.id){
            		 	form.submit(); 
            		 }else{
            		 	ctpMSB.alert({message:'<ctp:label key="select_branch_to_role"/>'});//请选择要进行角色管理的机构
            		 }           		 
            	 }
            	 catch (e) {
                     ctp.core.log.err(_mContext, e.message);
                 }            	 
            }
        </script>
        <script type='text/javascript' kind='notUi'>
            //================================非UI组件定义片段==========================================================
        </script>
		<script type='text/javascript' kind='ui'>
		    //================================UI组件定义片段============================================================		    
		    //ctp.core.log.lvl = ctp.core.loglvl.obj; //需要进行调试时启用
		    /**
             * 创建UI组件
             * @version	 1.0
             * @since	 1.0
             * @author	KFZX-tangk           
             */		    
		    function initUI(){
		    	 var _mContext = "branchlist_role.jsp -> initUI()";
            	 try {

                     //创建工具栏上搜索文本框
            		 toolbarSearchT=new ctp.ui.textfield({width: '100px'});
                     //创建工具栏
            		 toolbar=new ctp.ui.toolbar({
					 	width: 'auto',			
						border : 'bottom',			
				    	leftItems :[{
				    		id: 'btnOK',
				        	type : 'button',
				        	text : '<ctp:label key="confirm" />',
				        	icon : 'apply',
				        	disabled: true,
				        	onClick : formSubmit
				        }],
				    	rightItems :[{
				        	type : 'textfield',
				        	text : '<ctp:label key="search" />：',
				        	object: toolbarSearchT
				        },{
					    	type : 'button',
					    	icon : 'search',
					    	onClick : toolbarSearch
					    }]
					 });
			         //创建保存机构列表的面板
				     branchTreePanel=new ctp.ui.panel({
						id:'tableTreePanelId',
						title: '<ctp:label key="role_branch_list" />',
						toolbar:toolbar,
						toolbarPos:'innertop',
						collapsible: true,
						width: '100%',
						//height: 'auto',
					//	visible: 'visible',
						bodyPadding: '0'			   
					});
     			     
     			    //创建页面跳转表单
					form=new ctp.form({
						 id: 'branchlist_role',
						 width: '90%', //宽度
				   		 postType:'normal'
					 });

           		 //创建页面布局
           		 layout=new ctp.ui.borderlayout({
       			 	type: "1C",
       				center__size: 1,
       				//center__scrollable:true,
       				center__items:[branchTreePanel],
       		        renderTo:'body'
					 }); 
           		 
           		//创建机构列表
  			    branchTree=cteateBranchTree(branchTreePanel,roleMgmt);
            	 }	
            	catch (e) {
                     ctp.core.log.err(_mContext, e.message);
                }
		    }   
		</script>
	</head>
	<body onload='initUI();'>	    
		<ctp:form name="branchlist_role" method="post" action="rolemgmt.flowc" flowActionName="jumpop">
			<input type="hidden" name="branchId">
			<input type="hidden" name="branchLevel">
			<input type="hidden" name="branchParent">
			<input type="hidden" name="branchName">
		</ctp:form>
	</body>
</html>

<%--
	date        :
	modifyReason:
--%>